home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / src / test / test5.sml < prev    next >
Encoding:
Text File  |  1997-08-18  |  379 b   |  20 lines  |  [TEXT/R*ch]

  1. let val r = ref []
  2. in r := [7]; !r end;
  3.  
  4. fun Id x = let val r = ref x in !r end;
  5. fun Id' x = Id Id x;
  6.  
  7. fun reverse l =
  8.   let val res = ref []
  9.       fun loop [] = !res
  10.         | loop (hd :: tl) = (res:= hd::(!res); loop tl)
  11.   in loop l end;
  12.  
  13. reverse [1,2,3];
  14. reverse [true,false];
  15.  
  16. val f = fn x as ref u => (x := 666; (x, u));
  17. f (ref 99);
  18.  
  19. let fun plus x y = x+y in plus 3 5 end;
  20.